<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Log;

class WishModel extends Model
{
    //定义一个表名
    protected $table = 'user_wish';
    //定义主键
    protected $primaryKey = 'id';
    protected $guarded = [];

    function getUserAttribute(){
        $user = UserModel::where('id',$this->uid)->first();
        if($user['phone']){
            return $user['phone'];
        }else{
            return $user['email'];
        }
    }

    function getEndAttribute(){
        if($this->wish_end_time){
            return $this->wish_end_time;
        }else{
            return "暂无";
        }
    }

    function getOverAttribute(){
        if($this->over_time){
            return $this->over_time;
        }else{
            return "暂无";
        }
    }

    function getInNumsAttribute(){
        $nums = UserWishLog::where('wid',$this->id)->count();
        return $nums;
    }
}
